package com.byzk.p2p.admin.system.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.byzk.p2p.admin.base.util.PageInfo;
import com.byzk.p2p.admin.system.dao.GoodBuyDao;
import com.byzk.p2p.admin.system.dto.GoodBuy;
import com.byzk.p2p.admin.system.vo.GoodBuyExportVo;
import com.byzk.p2p.admin.system.vo.GoodBuyVo;

@Service
public class GoodBuyService {

	@Autowired
	private GoodBuyDao goodBuyDao;

	/**
	 * 查询购买记录
	 * 
	 * @param index
	 * @param limit
	 * @return
	 */
	public PageInfo<GoodBuyVo> listGoodBuy(GoodBuyVo info) {
		int count = goodBuyDao.count(info);
		List<GoodBuyVo> voList = goodBuyDao.list(info);
		PageInfo<GoodBuyVo> page = new PageInfo<GoodBuyVo>(count, info.getIndex(), info.getLimit());
		page.setPageList(voList);
		return page;
	}

	/**
	 *详情
	 */
	public GoodBuy detail(Integer id) {
		return goodBuyDao.selectById(id);
	}

	public Integer saveOrUpdate(GoodBuy oodBuy) {
		if (oodBuy.getId() == null) {
			return goodBuyDao.insert(oodBuy);
		} else {
			return goodBuyDao.update(oodBuy);
		}
	}

	public Integer delete(Integer id) {
		return goodBuyDao.delete(id);
	}

	public List<GoodBuy> new5GoodBuyList(){
		return goodBuyDao.new5GoodBuyList();
	}
	
	public List<GoodBuyVo> exportList(GoodBuyExportVo vo){
		return goodBuyDao.listByExportVo(vo);
	}
	
}
